home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 10
/
AACD 10.iso
/
AACD
/
Programming
/
AmigaTalk
/
general
/
Semaphore.st
< prev
next >
Wrap
Text File
|
2000-02-16
|
800b
|
32 lines
"-----------------------------------------------------------"
" Semaphore Class is NOT the same as Amiga Exec Semaphores. "
"-----------------------------------------------------------"
Class Semaphore :List
! excessSignals !
[
new
excessSignals <- 0
|
new: aNumber
excessSignals <- aNumber
|
signal
<primitive 148>. "start atomic action"
(self isEmpty)
ifTrue: [excessSignals <- excessSignals + 1]
ifFalse: [self removeFirst unblock].
<primitive 149> "end atomic action"
|
wait
<primitive 148>. "start atomic actions"
(excessSignals = 0)
ifTrue: [self addLast: selfProcess. selfProcess block]
ifFalse: [excessSignals <- excessSignals - 1].
<primitive 149> "end atomic actions"
]